package com.jijs.ws;

import java.util.ArrayList;
import java.util.List;

import javax.xml.ws.handler.Handler;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import com.jijs.ws.handler.LicenseHandler;
import com.jijs.ws.interceptor.LicenseUserInInterceptor;

public class MyServer {

	public static void main(String[] args) {
		
//		Endpoint.publish("http://localhost:8080/ws", new MyService());
		//CXF提供了另外一个方法
		JaxWsServerFactoryBean fac = new JaxWsServerFactoryBean();
		fac.setAddress("http://localhost:8080/ws");
		fac.setServiceBean(new MyService());
		fac.setServiceClass(IMyService.class);
		//可以通过拦截器处理更多的SOAP请求
		fac.getInInterceptors().add(new LoggingInInterceptor());
//		fac.getOutInterceptors().add(new LoggingOutInterceptor());
		
		//处理handler
//		List<Handler> list = new ArrayList<Handler>();
//		list.add(new LicenseHandler());
//		fac.addHandlers(list);
		
		
		fac.getInInterceptors().add(new LicenseUserInInterceptor());
		fac.create();
	}
}
